<style>
    /* 打开宽度限制 */
    .popover {
        max-width: 40vw;
    }
</style>
<div id="saleinvoice">
    <div class="container-fluid">
        <div class="row clearfix">
            <div class="col-md-12 column">
                <div class="alert alert-dismissable alert-info" id="headeralert">
                    <button type="button" class="close">×</button>
                    <p></p>
                </div>
            </div>
        </div>
        <div class="ntDesktop">
            <div class="ntDesktop-head">销售财务界面（开票员-发票）</div>

            <div class="row" style="padding-top:0px">
                <div class="col-md-7">
                    <ul class="nav nav-tabs">
                        <li class="active" @click="changstatus(1)">
                            <a href="#new" data-toggle="tab">
                                待开票 <span class="label label-info">{{countnum.countnumone}}</span>
                            </a>
                        </li>
                        <li @click="changstatus(2)">
                            <a href="#finish" data-toggle="tab">
                                已完成 <span class="label label-default">{{countnum.countnumtwo}}</span>
                            </a>
                        </li>
                        <li @click="changstatus(3)">
                            <a href="#cancel" data-toggle="tab">
                                已取消 <span class="label label-info">{{countnum.countnumthree}}</span>
                            </a>
                        </li>
                        <li @click="changstatus(4)">
                            <a href="#delete" data-toggle="tab">
                                已删除 <span class="label label-default">{{countnum.countnumfour}}</span>
                            </a>
                        </li>
                    </ul>
                </div>
                <div class="col-md-5">
                    <div class="col-md-8">
                        <div class="input-group">
                            <input type="text" class="form-control" placeholder="输入公司名或订单号" @keyup.13="render"
                                   v-model="dname">
                            <div class="input-group-btn">
                                <button class="btn btn-primary" @click="render"><span class="fa fa-search"></span> 查找
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row tab-content">

                <!-- 收款 待开票银行单 列表 -->
                <div class="col-md-12 tab-pane active" id="new">
                    <table class="table table-striped table-hover ntTable">
                        <thead>
                        <tr>
                            <th width="4%"> 订单号</th>
                            <th width="4%"> 优先级</th>
                            <th> 时间</th>
                            <th width="30%"> 公司名称</th>
                            <th> 发票</th>
                            <th> 金额</th>
                            <th> 业务员</th>
                            <th> 编辑</th>
                            <th> 备注</th>
                            <th> 操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr v-for="item in list" :key="item.id">
                            <td>{{formatUnit(item.sale_id,'ID')}}</td>
                            <td align="center"><span class="label label-info">{{item.priority}}</span></td>
                            <td class="text-success"><b>{{item.interval_time}}</b></td>
                            <td>
                                {{item.company_name}}<br>
                                <span class="label label-info">{{item.company_branch_name}}</span>
                            </td>
                            <td>{{item.code}}</td>
                            <td align="right">{{formatUnit(item.pay,'BRL')}}
                                <small class="unit">BRL</small>
                            </td>
                            <td>{{item.saler_name}}</td>
                            <td>{{item.managename}}<br>
                                <small>{{item.update_date}}</small>
                            </td>
                            <td>
                                <button v-if="item.remark.length>0" @mouseover="setpopper" class="btn btn-sm btn-default"
                                        data-toggle="popover" title="付款登记（8888）备注">
                                    备注
                                    <div class="content">
                                        <div style="width:30vw">
                                            <ul>
                                                <li v-for="remarkname in item.remark" :key="remarkname.id">
                                                    {{remarkname.remark}}
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                </button>
                            </td>
                            <td align="right">
                                {in name="256" value="$Think.session.admin.auth_ids"}
                                <button @click="activeinvoice(item.id,1)" class="btn btn-sm btn-primary"
                                        data-toggle="modal"
                                        data-target="#invoice_editModal">开发票
                                </button>
                                {/in}
                            </td>
                        </tr>
                        <tr style="text-align: center;" v-if="list.length==0">
                            <td colspan="10" class="no_date">{:strtoupper(lang('no_data'))}</td>
                        </tr>
                        </tbody>
                    </table>
                    <div class="row clearfix">
                        <div class="col-md-12 column">
                            <ul class="pagination" id="paginationone" v-show="list.length!=0">
                            </ul>
                        </div>
                    </div>
                </div>

                <!-- 财务- 完成登记发票 列表 -->
                <div class="col-md-12 tab-pane" id="finish">
                    <table class="table table-striped table-hover ntTable">
                        <thead>
                        <tr>
                            <th width="4%"> 订单号</th>
                            <th width="30%"> 公司名称</th>
                            <th> 金额</th>
                            <th> 类型</th>
                            <th> 发票</th>
                            <th> 业务员</th>
                            <th> 编辑</th>
                            <th> 备注</th>
                            <th> 操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr v-for="item in list" :key="item.id">
                            <td>{{formatUnit(item.sale_id,'ID')}}</td>
                            <td>
                                {{item.company_name}}<br>
                                <span class="label label-info">{{item.company_branch_name}}</span>
                            </td>
                            <td align="right">{{formatUnit(item.pay,'BRL')}}
                                <small class="unit">BRL</small>
                            </td>
                            <td>{{item.code}}</td>
                            <td>
                                {{item.number}}<br>
                                {{item.drawername}} / {{item.drawer_date}}
                            </td>
                            <td>{{item.saler_name}}</td>
                            <td>{{item.managename}}<br>
                                <small>{{item.update_date}}</small>
                            </td>
                            <td>
                                <button v-if="item.remark.length>0" @mouseover="setpopper" class="btn btn-sm btn-default"
                                        data-toggle="popover" title="付款登记（8888）备注">
                                    备注
                                    <div class="content">
                                        <div style="width:30vw">
                                            <ul>
                                                <li v-for="remarkname in item.remark" :key="remarkname.id">
                                                    {{remarkname.remark}}
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                </button>
                            </td>
                            <td align="right">
                                {in name="256" value="$Think.session.admin.auth_ids"}
                                <button @click="activeinvoice(item.id,2)" class="btn btn-sm btn-default"
                                        data-toggle="modal"
                                        data-target="#invoice_viewModal">查看
                                </button>
                                {/in}
                                {in name="256" value="$Think.session.admin.auth_ids"}
                                <button @click="activeinvoice(item.id,1)" class="btn btn-sm btn-primary"
                                        data-toggle="modal"
                                        data-target="#invoice_editModal">编辑
                                </button>
                                {/in}
                                {in name="257" value="$Think.session.admin.auth_ids"}
                                <button class="btn btn-sm btn-default"
                                        @click="delremuseinvoice(item.id,item.sale_id,1)">删除
                                </button>
                                {/in}
                            </td>
                        </tr>
                        <tr style="text-align: center;" v-if="list.length==0">
                            <td colspan="9" class="no_date">{:strtoupper(lang('no_data'))}</td>
                        </tr>
                        </tbody>
                    </table>
                    <div class="row clearfix">
                        <div class="col-md-12 column">
                            <ul class="pagination" id="paginationtwo" v-show="list.length!=0">
                            </ul>
                        </div>
                    </div>
                </div>


                <!-- 财务- 已取消发票 列表 -->
                <div class="col-md-12 tab-pane" id="cancel">
                    <table class="table table-striped table-hover ntTable">
                        <thead>
                        <tr>
                            <th width="4%"> 订单号</th>
                            <th width="30%"> 公司名称</th>
                            <th> 金额</th>
                            <th> 类型</th>
                            <th> 发票</th>
                            <th> 业务员</th>
                            <th> 编辑</th>
                            <th> 备注</th>
                            <th> 操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr v-for="item in list" :key="item.id">
                            <td>{{formatUnit(item.sale_id,'ID')}}</td>
                            <td>
                                {{item.company_name}}<br>
                                <span class="label label-info">{{item.company_branch_name}}</span>
                            </td>
                            <td align="right">{{formatUnit(item.pay,'BRL')}}
                                <small class="unit">BRL</small>
                            </td>
                            <td>{{item.code}}</td>
                            <td>
                                {{item.number}}<br>
                                {{item.drawername}} / {{item.drawer_date}}
                            </td>
                            <td>{{item.saler_name}}</td>
                            <td>{{item.managename}}<br>
                                <small>{{item.update_date}}</small>
                            </td>
                            <td>
                                <button v-if="item.remark.length>0" @mouseover="setpopper" class="btn btn-sm btn-default"
                                        data-toggle="popover" title="付款登记（8888）备注">
                                    备注
                                    <div class="content">
                                        <div style="width:30vw">
                                            <ul>
                                                <li v-for="remarkname in item.remark" :key="remarkname.id">
                                                    {{remarkname.remark}}
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                </button>
                            </td>
                            <td align="right">
                                {in name="256" value="$Think.session.admin.auth_ids"}
                                <button @click="activeinvoice(item.id,2)" class="btn btn-sm btn-default"
                                        data-toggle="modal"
                                        data-target="#invoice_viewModal">查看
                                </button>
                                {/in}
                                {in name="258" value="$Think.session.admin.auth_ids"}
                                <button @click="delremuseinvoice(item.id,item.sale_id,2)"
                                        class="btn btn-sm btn-primary">删除
                                </button>
                                {/in}
                            </td>
                        </tr>
                        <tr style="text-align: center;" v-if="list.length==0">
                            <td colspan="9" class="no_date">{:strtoupper(lang('no_data'))}</td>
                        </tr>
                        </tbody>
                    </table>
                    <div class="row clearfix">
                        <div class="col-md-12 column">
                            <ul class="pagination" id="paginationthree" v-show="list.length!=0">
                            </ul>
                        </div>
                    </div>
                </div>


                <!-- 财务- 已删除发票 列表 -->
                <div class="col-md-12 tab-pane" id="delete">
                    <table class="table table-striped table-hover ntTable">
                        <thead>
                        <tr>
                            <th width="4%"> 订单号</th>
                            <th width="30%"> 公司名称</th>
                            <th> 金额</th>
                            <th> 类型</th>
                            <th> 发票</th>
                            <th> 业务员</th>
                            <th> 编辑</th>
                            <th> 备注</th>
                            <th> 操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr v-for="item in list" :key="item.id">
                            <td>{{formatUnit(item.sale_id,'ID')}}</td>
                            <td>
                                {{item.company_name}}<br>
                                <span class="label label-info">{{item.company_branch_name}}</span>
                            </td>
                            <td align="right">{{formatUnit(item.pay,'BRL')}}
                                <small class="unit">BRL</small>
                            </td>
                            <td>{{item.code}}</td>
                            <td>
                                {{item.number}}<br>
                                {{item.drawername}} / {{item.drawer_date}}
                            </td>
                            <td>{{item.saler_name}}</td>
                            <td>{{item.managename}}<br>
                                <small>{{item.update_date}}</small>
                            </td>
                            <td>
                                <button v-if="item.remark.length>0" @mouseover="setpopper" class="btn btn-sm btn-default"
                                        data-toggle="popover" title="付款登记（8888）备注">
                                    备注
                                    <div class="content">
                                        <div style="width:30vw;">
                                            <ul>
                                                <li v-for="remarkname in item.remark" :key="remarkname.id">
                                                    {{remarkname.remark}}
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                </button>
                            </td>
                            <td align="right">
                                {in name="256" value="$Think.session.admin.auth_ids"}
                                <button @click="activeinvoice(item.id,2)" class="btn btn-sm btn-default"
                                        data-toggle="modal"
                                        data-target="#invoice_viewModal">查看
                                </button>
                                {/in}
                                {in name="259" value="$Think.session.admin.auth_ids"}
                                <button @click="delremuseinvoice(item.id,item.sale_id,3)"
                                        class="btn btn-sm btn-primary">恢复
                                </button>
                                {/in}
                            </td>
                        </tr>
                        <tr style="text-align: center;" v-if="list.length==0">
                            <td colspan="9" class="no_date">{:strtoupper(lang('no_data'))}</td>
                        </tr>
                        </tbody>
                    </table>
                    <div class="row clearfix">
                        <div class="col-md-12 column">
                            <ul class="pagination" id="paginationfour" v-show="list.length!=0">
                            </ul>
                        </div>
                    </div>
                </div>


            </div>

        </div>
    </div>
    <!-- 销售财务 发票 查看开始 -->
    <div class="modal fade" id="invoice_viewModal" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog modal-lg" style="width:80%">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">订单（8888）发票查看编辑</h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-4">
                            <table class="table table-hover ntTable">
                                <tbody>
                                <tr>
                                    <td width="20%">订单号</td>
                                    <td>{{formatUnit(leftdata.sale_id,'ID')}}</td>
                                </tr>
                                <tr>
                                    <td>公司</td>
                                    <td class="text-primary">{{leftdata.company_name}}</td>
                                </tr>
                                <tr>
                                    <td>营业号</td>
                                    <td>{{leftdata.regno}}</td>
                                </tr>
                                <tr>
                                    <td>税号</td>
                                    <td>{{leftdata.taxno}}</td>
                                </tr>
                                <tr>
                                    <td>分公司</td>
                                    <td class="text-primary">{{leftdata.co_branch_name}}</td>
                                </tr>
                                <tr>
                                    <td>营业号</td>
                                    <td>{{leftdata.regnos}}</td>
                                </tr>
                                <tr>
                                    <td>税号</td>
                                    <td>{{leftdata.taxnos}}</td>
                                </tr>
                                <tr>
                                    <td>发票类型</td>
                                    <td>{{leftdata.code}}</td>
                                </tr>
                                <tr>
                                    <td>发票号</td>
                                    <td>{{leftdata.number}}</td>
                                </tr>
                                <tr>
                                    <td>开票</td>
                                    <td>{{leftdata.drawername}}/{{leftdata.drawertime}}</td>
                                </tr>
                                <tr>
                                    <td>更新</td>
                                    <td>{{leftdata.upl_name}}/{{leftdata.upl_date}}</td>
                                </tr>
                                <tr>
                                    <td>删除</td>
                                    <td>{{leftdata.del_name}}/{{leftdata.del_date}}</td>
                                </tr>
                                </tbody>
                            </table>
                        </div>

                        <div class="col-md-8">
                            <div class="div-scrol" style="max-height:50vh">
                                <table class="table table-hover ntTable">
                                    <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>产品</th>
                                        <th>数量</th>
                                        <th>单价</th>
                                        <th>合计</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr v-for="(item ,index) in rightdata" :key="item.id">
                                        <td align="center">{{index+1}}</td>
                                        <td>
                                            <div class="pro">
                                                <div class="pro-icon">
                                                    <img :src="item.pro_data.img_url" border="0" width="48px"
                                                         height="48px">
                                                </div>
                                                <div class="pro-name">
                                                    <small> {{formatUnit(item.pro_data.pro_id,'ID') + (item.pro_data.brand_name ? ' / '+item.pro_data.brand_name :'')+ (item.pro_data.model ? ' / '+item.pro_data.model :'')}}
                                                    </small>
                                                    <br>
                                                    {{item.pro_data.pro_name}}
                                                </div>
                                            </div>
                                        </td>
                                        <td align="right">{{formatUnit(item.qty,'PCS')}}
                                            <small class="unit">PCS</small>
                                        </td>
                                        <td align="right">{{formatUnit(item.price,'BRL')}}
                                            <small class="unit">BRL</small>
                                        </td>
                                        <td align="right">{{formatUnit(item.price*item.qty,'BRL')}}
                                            <small class="unit">BRL</small>
                                        </td>
                                    </tr>
                                    <tr style="text-align: center;" v-if="rightdata.length==0">
                                        <td colspan="5" class="no_date">{:strtoupper(lang('no_data'))}</td>
                                    </tr>
                                    </tbody>
                                    <tfoot>
                                    <tr>
                                        <td colspan="5" align="right">
                                            合计: {{formatUnit(sumcount,'BRL')}}
                                            <small class="unit">BRL</small>
                                        </td>
                                    </tr>
                                    </tfoot>
                                </table>
                            </div>

                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span
                            class="glyphicon glyphicon-remove"></span>取消
                    </button>
                    <button type="button" class="btn btn-primary" data-dismiss="modal"
                            style="padding-left:24px;padding-right:24px">
                        <span class="fa fa-save"></span>保存
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!-- 销售财务 发票 编辑开始 -->
    <div class="modal fade" id="invoice_editModal" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog modal-lg" style="width:80%">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">订单（8888）发票编辑</h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="row clearfix">
                            <div class="col-md-12 column">
                                <div class="alert alert-dismissable alert-info">
                                    <button type="button" class="close">×</button>
                                    <p></p>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-4">
                            <table class="table table-hover ntTable">
                                <tbody>
                                <tr>
                                    <td width="20%">订单号</td>
                                    <td>{{formatUnit(leftdata.sale_id,'ID')}}</td>
                                </tr>
                                <tr>
                                    <td>公司</td>
                                    <td class="text-primary">{{leftdata.company_name}}</td>
                                </tr>
                                <tr>
                                    <td>营业号</td>
                                    <td>{{leftdata.regno}}</td>
                                </tr>
                                <tr>
                                    <td>税号</td>
                                    <td>{{leftdata.taxno}}</td>
                                </tr>
                                <tr>
                                    <td>分公司</td>
                                    <td class="text-primary">{{leftdata.co_branch_name}}</td>
                                </tr>
                                <tr>
                                    <td>营业号</td>
                                    <td>{{leftdata.regnos}}</td>
                                </tr>
                                <tr>
                                    <td>税号</td>
                                    <td>{{leftdata.taxnos}}</td>
                                </tr>
                                <tr>
                                    <td>发票类型</td>
                                    <td>{{leftdata.code}}</td>
                                </tr>
                                <tr>
                                    <td>发票号<span class="required"></span></td>
                                    <td>
                                        <input type="text" class="form-control" v-model="leftdata.number">
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <!---->
                        <div class="col-md-8">
                            <div class="div-scrol" style="max-height:50vh">
                                <table class="table table-hover ntTable">
                                    <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>产品</th>
                                        <th>数量</th>
                                        <th>单价</th>
                                        <th>合计</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr v-for="(item ,index) in rightdata" :key="item.id">
                                        <td align="center">{{index+1}}</td>
                                        <td>
                                            <div class="pro">
                                                <div class="pro-icon">
                                                    <img :src="item.pro_data.img_url" border="0" width="48px"
                                                         height="48px">
                                                </div>
                                                <div class="pro-name">
                                                    <small> {{formatUnit(item.pro_data.prochar_id,'ID') + (item.pro_data.brand_name ? ' / '+item.pro_data.brand_name :'')+ (item.pro_data.model ? ' / '+item.pro_data.model :'')}}
                                                    </small>
                                                    <br>
                                                    {{item.pro_data.pro_name}}
                                                </div>
                                            </div>
                                        </td>
                                        <td align="right">{{formatUnit(item.qty,'PCS')}}
                                            <small class="unit">PCS</small>
                                        </td>
                                        <td align="right">{{formatUnit(item.price,'BRL')}}
                                            <small class="unit">BRL</small>
                                        </td>
                                        <td align="right">{{formatUnit(item.price*item.qty,'BRL')}}
                                            <small class="unit">BRL</small>
                                        </td>
                                    </tr>
                                    <tr style="text-align: center;" v-if="rightdata.length==0">
                                        <td colspan="5" class="no_date">{:strtoupper(lang('no_data'))}</td>
                                    </tr>
                                    </tbody>
                                    <tfoot>
                                    <tr>
                                        <td colspan="5" align="right">
                                            合计: {{formatUnit(sumcount,'BRL')}}
                                            <small class="unit">BRL</small>
                                        </td>
                                    </tr>
                                    </tfoot>
                                </table>
                            </div>

                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span
                            class="glyphicon glyphicon-remove"></span>取消
                    </button>
                    <button type="button" class="btn btn-primary" @click="savebtn"
                            style="padding-left:24px;padding-right:24px">
                        <span class="fa fa-save"></span>保存
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>

{include file="public/foot"/}
<!--弹窗部分 结束-->
<script>
    var table = new Vue({
        el: '#saleinvoice',
        data: {
            list: [],
            status: '1',
            page: '1',
            pageSize: 30,
            //头部数字
            countnum: {
                countnumone: '',
                countnumtwo: '',
                countnumthree: '',
                countnumfour: '',
            },
            dname: '',
            leftdata: {},
            rightdata: {},
        },
        computed: {
            sumcount(){
                var s = 0;
                if (this.rightdata.length > 0) {
                    this.rightdata.forEach(e => {
                        s += e.price * e.qty;
                    });
                }
                return s;
            }
        },
        methods: {
            formatUnit: formatUnit,
            setPage(pageCurrent, pageSum, pagination) {
                //数据总条数
                var myPageCount = pageSum;
                //一页显示多少条
                var myPageSize = this.pageSize;
                //总页数
                var countindex = myPageCount % myPageSize > 0 ? (myPageCount / myPageSize) + 1 : (myPageCount / myPageSize);
                $.jqPaginator(pagination, {
                    totalPages: parseInt(countindex),
                    //最多显示多少页
                    visiblePages: 5,
                    //默认显示第几页
                    currentPage: pageCurrent,
                    first: '<li class="first"><a href="javascript:;">' + langcon.page_home + '</a></li>',
                    prev: '<li class="prev"><a href="javascript:;"><i class="arrow arrow2"></i>' + langcon.previous_page + '</a></li>',
                    next: '<li class="next"><a href="javascript:;">' + langcon.next_page + '<i class="arrow arrow3"></i></a></li>',
                    last: '<li class="last"><a href="javascript:;">' + langcon.last_page + '</a></li>',
                    page: '<li class="page"><a href="javascript:;">{{page}}</a></li>',
                    all: '<li class="page"><a href="javascript:;">' + myPageCount + ' / ' + this.page + 'PG , ' + this.pageSize + ' /PG</a></li>',
                    onPageChange: (num, type) => {
                        if (type == "change") {
                            this.page = num
                            this.getAllList()
                        }
                    }
                });
            },
            //数据所有获取
            getAllList(){
                $('.loding').show();
                $.ajax({
                    url: "/admin/finance/saleinvoice",
                    type: 'post',
                    data: {
                        status: this.status,//页面标签
                        getdata: '',//获取标志
                        dname: this.dname,//搜索
                        page: this.page,
                        pageSize: this.pageSize,
                    },
                    dataType: "json",
                    success: (result) => {
                        $('.loding').hide();
                        this.list = result.data;
                        this.countnum.countnumone = result.arrcount.one;
                        this.countnum.countnumtwo = result.arrcount.two;
                        this.countnum.countnumthree = result.arrcount.three;
                        this.countnum.countnumfour = result.arrcount.four;
                        let pagination = '';
                        if (this.status == 1) {
                            pagination = '#paginationone';
                        } else if (this.status == 2) {
                            pagination = '#paginationtwo';
                        } else if (this.status == 3) {
                            pagination = '#paginationthree';
                        } else if (this.status == 4) {
                            pagination = '#paginationfour';
                        }
                        if (result.count) {
                            $('.loding').hide()
                            this.setPage(parseInt(this.page), result.count, pagination)
                        }
                    }
                })
            },
            timer(){
                if (this.status == 1) {
                    this.list.forEach(e => {
                        var start = e.interval_time.split(":");
                        var one = start[0];//小时
                        var two = start[1];//分
                        var three = start[2];//秒
                        three++
                        if (three == 60) {
                            two++;
                            if (two == 60) {
                                one++
                                two = 0
                            }
                            three = 0
                        }
                        if (one.toString().length == 1) {
                            one = '0' + one
                        }
                        if (two.toString().length == 1) {
                            two = '0' + two
                        }
                        if (three.toString().length == 1) {
                            three = '0' + three
                        }
                        e.interval_time = one + ':' + two + ":" + three
                    });
                }
            },
            //查找
            render(){
                //搜索条件满足才进行搜索
                this.getAllList()
            },
            //标签切换
            changstatus(status){
                this.status = status;
                this.getAllList()
            },
            //隐藏需要隐藏的部分
            datapopover(){
                $.each($("[data-toggle='popover']"), (key, value) => {
                    $(value).find(".content").hide();
                })
            },
            //设置popper组件的配置
            setpopper(e){
                $(e.target).popover({
                    trigger: 'hover focus manual',
                    placement: ($(e.target).attr("placement") == undefined) ? 'left' : $(e.target).attr("placement"),
                    //placement:'left',
                    title: $(e.target).attr("title"),
                    html: 'true',
                    content: $(e.target).find(".content").html(),
                    animation: false
                });
            },
            //开发票 查看 编辑
            activeinvoice(id, code){
                $.ajax({
                    url: "/admin/finance/codeinvoice",
                    type: 'post',
                    data: {
                        id,
                        code
                    },
                    dataType: "json",
                    success: (result) => {
                        this.leftdata = result.leftdata;
                        this.rightdata = result.rightdata;
                    }
                })
            },
            //开发票中的保存 查看 编辑
            savebtn(){
                $.ajax({
                    url: "/admin/finance/codeinvoice",
                    type: 'post',
                    data: {
                        leftdata: this.leftdata
                    },
                    dataType: "json",
                    success: (result) => {
                        if (result.status != 1) {
                            change_mes_type('.modal-body .alert', result.status)
                            $('.modal-body .alert').show()
                            $('.modal-body .alert p').html('*' + result.msg + '<br>')
                        } else {
                            change_mes_type('#headeralert', result.status)
                            $('#headeralert').show()
                            $('#headeralert p').html('*' + result.msg + '<br>')
                            if (result.status == 1) {
                                this.getAllList();
                            }
                            $('#invoice_editModal').modal('toggle')
                        }
                    }
                })
            },
            //删除 恢复按钮
            delremuseinvoice(id, sale_id, code){
                var requesturl = '';
                if (code == 1) {
                    requesturl = 'invoicedelone'
                } else if (code == 2) {
                    requesturl = 'invoicedeltwo'
                } else if (code == 3) {
                    requesturl = 'resume';
                }
                $.ajax({
                    url: "/admin/finance/" + requesturl,
                    type: 'post',
                    data: {
                        id,
                        sale_id
                    },
                    dataType: "json",
                    success: (result) => {
                        change_mes_type('#headeralert', result.status)
                        $('#headeralert').show()
                        $('#headeralert p').html(result.msg)
                        if (result.status == 1) {
                            this.getAllList()
                        }

                    }
                })
            }
        },
        created(){
            setInterval(this.timer, 1000);
            this.getAllList();//数据
            this.datapopover();
        }
    })
    $("#invoice_editModal").on("hidden.bs.modal", function () {
        $(this).removeData("bs.modal");
        $(document).unbind('keydown')
    });
    $("#invoice_viewModal").on("hidden.bs.modal", function () {
        $(this).removeData("bs.modal");
        $(document).unbind('keydown')
    });
</script>